interface Strategy {
  strategyMethod(): void
}

class ConcreteStrategyA implements Strategy {
  strategyMethod(): void {
    console.log('实现策略A');
  }

}

class ConcreteStrategyB implements Strategy {
  strategyMethod(): void {
    console.log('实现策略B');
  }
}

class StrategyContext {
  private _strategy: Strategy

  setStrategy(strategy: Strategy) {
    this._strategy = strategy
  }
  getStrategy(): Strategy {
    return this._strategy
  }
  strategyMethod(): void {
    this._strategy.strategyMethod()
  }
}

function main() {
  const c = new StrategyContext();
  let s = new ConcreteStrategyA();
  c.setStrategy(s);
  c.strategyMethod();
  console.log("-----------------");
  s = new ConcreteStrategyB();
  c.setStrategy(s);
  c.strategyMethod();
}

main()